//
//  SRSportShareHeaderView.m
//  SportRing
//
//  Created by icelee on 14-10-29.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "SRSportShareHeaderView.h"
#import "SRMe+Cate.h"
#import "UIView+Cat.h"
#import <UIImageView+AFNetworking.h>

@implementation SRSportShareHeaderViewModel



@end

@interface SRSportShareHeaderView()

@property (nonatomic, weak)IBOutlet UIImageView *headerBackgroundImageView;
@property (nonatomic, weak)IBOutlet UIImageView *headerImageViw;
@property (nonatomic, weak)IBOutlet UILabel *dateLabel;
@property (nonatomic, weak)IBOutlet UILabel *userNameLabel;

@end

@implementation SRSportShareHeaderView

- (void)setSRSportShareHeaderViewDataWithModel:(SRSportShareHeaderViewModel *)model
{
    if (self.shareType == SR_SHARE_TYPE_DAY_SPORT || self.shareType == SR_SHARE_TYPE_MONTH_SPORT)
    {
        self.headerBackgroundImageView.image = [UIImage imageNamed:@"share_green_top_bg"];
        
        self.userNameLabel.textColor = [UIColor whiteColor];
        
    }
    if (self.shareType == SR_SHARE_TYPE_DAY_SLEEPING || self.shareType == SR_SHARE_TYPE_MONTH_SLEEPING)
    {
        self.headerBackgroundImageView.image = [UIImage imageNamed:@"share_blue_top_bg"];
        
        self.userNameLabel.textColor = [UIColor whiteColor];
    }
    
    if ([[SRMe currentUser].gender integerValue] == SRGenderMale)
    {
        self.headerImageViw.image = [UIImage imageNamed:@"select_gender_male"];
        
    }
    else
    {
        self.headerImageViw.image = [UIImage imageNamed:@"select_gender_female"];
    }
    
    SRMe * me = [SRMe currentUser];
    if (me.headPhoto.length > 0) {
        [self.headerImageViw setImageWithURL:[NSURL URLWithString:me.headPhoto]];
    }
    [self.headerImageViw roundedCornerWithRadius:CGRectGetWidth(self.headerImageViw.bounds) / 2
                                      borderColor:[UIColor lightGrayColor]
                                      borderWidth:0.5f];
    
    if (!model)
    {
        return;
    }
    self.dateLabel.text = model.date;
    self.userNameLabel.text = model.name;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
